{include file="admin@public/header" /}

<style>
    #matchCon {
        width: 100px;
    }

    .grid-wrap {
        position: relative;
    }

    .container {
        padding: 10px 20px;
    }

    .ui-btn {
        padding: 0 17px;
        height: 25px;
        line-height: 25px;
        margin-bottom: 10px;
    }

    .plus {
        background: url("/public/static/admin/css/img/plus.png") no-repeat center;
        vertical-align: middle;
        padding: 13px;
        margin: auto;
    }

    .reduce {
        background: url("/public/static/admin/css/img/reduce.png")no-repeat center;
        vertical-align: middle;
        padding: 13px;
        margin: auto
    }

    .right {
        background: url("/public/static/admin/css/img/right.png") no-repeat center;
        vertical-align: middle;
        padding: 13px;
        margin: auto
    }

    .hint {
        padding: 0 20px;
        width: 100%;
        vertical-align: text-bottom;
    }
</style>

<div class="container fix p20">
    <a class="ui-btn" id="modify" onclick="updades()">修改</a>
    <div class="grid-wrap">
        <table id="grid">
        </table>
        <div id="page"></div>
    </div>
</div>
<span class="hint">
    图释:
    <span class="right hint"></span><span>匹配的序列号</span>
    <span class="reduce hint"></span><span>盘亏的序列号</span>
    <span class="plus hint"></span><span>盘盈的序列号</span>
</span>

<div style="display: none;">
    <input id="rightNum" value="{$rightNum}">
    <input id="addNum" value="{$addNum}">
    <input id="delNum" value="{$delNum}">
</div>

<script>
    $(document).ready(function () {
        $("#grid").jqGrid({
            url: '/store/inventorysn/sninventoryresult.html?ajax=100&store_id={$store_id}&good_id={$good_id}&sns={$new_sn}&systemSns={$system_sn}',
            datatype: "json",//数据来源，本地数据（local，json,jsonp,xml等）
            height: '323px',//高度，表格高度。可为数值、百分比或'auto'
            // width:'300px',
            colNames: ['系统库存序列号', '盘点状态'],
            colModel: [
                { name: 'sn', width: 238, label: "系统库存序列号" },
                { name: 'state', width: 114, label: "盘点状态",align:"center", formatter: stateFun },
            ],
            sortable: true,  //排序

            rowNum: 100,
            // rowList: [100, 200, 500],
            sortname: 'id',
            sortorder: "desc",
            pagerpos: "left",//分页位置

            pgbuttons: true,//翻页按钮
            rownumbers: true, //自增序号
            // pagination: true,
            pager: "#page",
        })

        
    });

    function stateFun(cellvalue, options, rowObject){
        var html="";
        if(rowObject.state==1){
            html='<span class="right"></span>'
        }else if(rowObject.state==2){
            html='<span class="plus"></span>'
        }else if(rowObject.state==3){
            html='<span class="reduce"></span>'
        }
        return html;
    }

    function updades(){

        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
        // setTimeout(() => {
        //     snFun({$store_id},{$good_id});
        // }, 0);
    }
    // 修改
    function snFun(store_id,good_id){
        console.log("aaa");
        // layer.close(index);
        
        
        parent.layer.open({
            type: 2,
            title: "实际库存序列号",
            shadeClose: true,
            shade: 0.3,
            maxmin: false, //开启最大化最小化按钮
            area: ['620px', '560px'],
            fixed: false, //不固定
            btn: ['确定', '取消'],
            content: "/store/inventorysn/sernumlist.html?store_id="+store_id+"&good_id="+good_id,
            btn1: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var sns=body.find("#snCon").val();
                var arr = sns.split('\n');
                var sn_arr=[];
                for(var i in arr){
                    if(arr[i]==""){
                        
                    }else{
                        sn_arr.push(arr[i]);
                    }
                }
                //console.log(sn_arr.length);

                // var num =parseFloat(sn_arr.length).toFixed(2);
                // $("#snNum_"+store_id+"_"+good_id).html(num);
                // $("#snBtn_"+store_id+"_"+good_id).addClass("qtyInsertAfter").removeClass("qtyInsert");
                
                resultFun(store_id,good_id);
                layer.close(index);
                return false;
            },
            btn2: function (index, layero) {
                layer.close(index);
                return false;
            }
        })
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    }
</script>


{include file="admin@public/footer" /}